﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>javascript的日期函数</title>
    <script type="text/javascript" language="javascript">
        function trydate()
        {
            var cdate=new Date();
            
            //alert(cdate.toDateString());
            //alert(cdate.toLocaleDateString());
            alert(cdate.getFullYear()+'-'+(cdate.getMonth()+1)+'-'+cdate.getDate());
        }
        
        function makedate()
        {
            var cdate=new Date('2008','10','7');
            cdate.setDate(cdate.getDate()+28);
            alert(cdate.toLocaleDateString());
        }
    </script>
</head>
<body>
    <input type="button" value="run" onclick="trydate()" /><br /><input type="button" value="run2" onclick="makedate()" />
</body>
</html>
